const {Project} = require('../model/index');


exports.getProject = async (limt = 10,skip =1)=>{
    
    const row = await Project.find().limit(limt).skip(limt*(skip-1));
    const count = await Project.find().count();

    
    return{
        row,
        count
    }

} 

exports.addProject = async (name,github,gitee,discription,thumb,Url='#',language = '')=>{

    const result = await Project.create({
        name,
        github,
        gitee,
        discription,
        thumb,
        Url,
        language
    });

    return result;


}
exports.upProject = async (_id,name,github,gitee,discription,thumb,Url='#',language = '')=>{

    const result = await Project.updateOne({_id},{
        $set:{
            name,
            github,
            gitee,
            discription,
            thumb,
            Url,
            language
        }
    })
    return result;
}

exports.delProject = async (_id)=>{
    const result = await Project.deleteOne({
        _id
    });

    return result;
}

